﻿using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;

public class Rune : MonoBehaviour
{
    public enum RuneType    // 宣告列舉OrbsType，包含所有珠子的屬性以及Null
    {
        Water,
        Fire,
        Earth,
        Light,
        Dark,
        Heart,
        Null
    }

    public RuneType type;   // 宣告珠子的類型
    private Image image;

    public int row;
    public int column;

    public float width = 120;
    public float height = 120;

    public List<Rune> linkRunes = new List<Rune>(); // 储存相近的符石（上下左右）
    public bool group = false;  // 判断该符石是否被分配群组
    public Text groupNum;   // 调试用：显示群组编号

    public bool removed = false;    // 判断符石是否消除
    public Text removeText; // 调试用：显示消除记号

    public int number;

    // 切换图片
    public void ChangeImage()
    {
        image.sprite = Resources.Load<Sprite>("RuneStone/" + type);    // 透過珠子的type更換圖片
    }

    private void Start()
    {
        image = GetComponent<Image>();
        ChangeImage();  // 宣告換圖用的函式，並在珠子初始化的時候執行一次

        transform.name = "rune" + row + column;

        GetComponent<RectTransform>().sizeDelta = new Vector2(width, height);

        GetComponent<CircleCollider2D>().offset = new Vector2(width / 2, height / 2);
        GetComponent<CircleCollider2D>().radius = width / 2 - 2;
    }
}
